<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>用户组授权管理</title>

    <!-- Bootstrap -->
    <link href="{:config('__public__')}/static/bootstrap-3.3.4/dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="http://cdn.bootcss.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="http://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>
<body>
<style type="text/css">
    dl {
        -webkit-margin-before: 1em;
        -webkit-margin-after: 1em;
        -webkit-margin-start: 0px;
        -webkit-margin-end: 0px;
    }
    dt {
        padding-left: 10px;
        height: 30px;
        line-height: 30px;
        font-weight: bold;
        border-bottom: 1px solid #ebebeb;
        background-color: #ECECEC;
    }
    dd {
        margin-left:20px; 
    }
    span {
        display: inline-block;
        margin-left: 0 ;/* !important*/
    }
    input{
        display: inline-block;
    }
    label {
        display: inline-block !important;
        cursor: default !important;
    }
    .checkmod {
        border-color: #ebebeb;
        border: 1px solid #ebebeb;
        margin-bottom: 20px;
    }

    .divsion {
        width: 20px;
        display: inline-block;
    }

    .rule_check{
        /*border-color: #ebebeb;
        border-width: 0;
        border-bottom: 1px; 
        border-style: dashed; */
    }

    .checkbox {
        display: inline-block;
        margin-left: 20px; 
        margin: 0 10px 0 0;
    }

    .child_row{
        padding-left: 30px; 
        display: inline-block;
    }


</style>
    <div class="main-title">
        <h2><span>{$this_group.title} </span> - 角色授权管理 </h2>
    </div>
    <ul class="nav nav-tabs" role="tablist">
        <li role="presentation" class="active">
            <a href="javascript:;">访问授权</a>
        </li>
        <li role="presentation">
            <a href="{:url('AuthManager/groupUsers',array('group_name'=>input('group_name') ,'group_id'=> input('group_id')))}">成员管理</a>
        </li>
        <li class="pull-right">
            分组选择：
            <select name="group">
                {volist name="auth_group" id="vo"}
                    <option value="{:url('AuthManager/access',array('group_id'=>$vo['id'],'group_name'=>$vo['title']))}" {eq name="vo['id']" value="$this_group['id']"}selected{/eq} >{$vo.title}</option>
                {/volist}
            </select>
        </li>
    </ul>
    <div class="container">
    <!-- <div class="pull-right menuClass row">
        {if $menu_module EQ 'admin'}
            <a class="btn btn-default active" href="{:url('access',['module'=>'admin'])}">后台菜单</a>
            <a class="btn btn-default" href="{:url('access',['module'=>'shop'])}">商城菜单</a>
        {else /}
            <a class="btn btn-default" href="{:url('access',['module'=>'admin'])}">后台菜单</a>
            <a class="btn btn-default active" href="{:url('access',['module'=>'shop'])}">商城菜单</a>
        {/if}
    </div> -->
	<!-- <div class="tab-wrap">
		<div class="tab-content"> -->
			<!-- 访问授权 -->
			<!-- <div class="tab-pane in"> -->
				<form action="{:url('AuthManager/updateAccess')}" enctype="application/x-www-form-urlencoded" method="POST" class="ajaxForm">
					{volist name="node_list" id="node" }
						<dl class="checkmod">
							<dt>
                                <input class="auth_rules rules_all" type="checkbox" name="rules[]" value="{$node.id}">{$node.title} -- {$node.module}
							</dt>
							<dd>
								{present name="node['_child']"}
								{volist name="node['_child']" id="child" }
                                    <div class="rule_check" >
                                        <div style="display: block;">
                                            <label class="checkbox" {notempty name="child['tip']"}title='{$child.tip}'{/notempty}>
                                            </label>
                                           <input class="auth_rules rules_row" type="checkbox" name="rules[]" value="{$child.id}"/>{$child.title}
                                        </div>
                                       {notempty name="child['_child']"}
                                           <!-- <span class="divsion">&nbsp;</span> -->
                                           <span class="child_row">
                                               {volist name="child['_child']" id="op"}
                                                    <div class="single" style="float: left;">
                                                   <label class="checkbox" {notempty name="op['tip']"}title='{$op.tip}'{/notempty}>
                                                   </label>
                                                       <input class="auth_rules" type="checkbox" name="rules[]"
                                                       value="{$op.id}"/>{$op.title}
                                                       </div>
                                               {/volist}

                                           </span>
                                       {/notempty}
				                    </div>
                                    <div class="" style="clear: both;"></div>
                                {/volist}
								{/present}
							</dd>
						</dl>
					{/volist}

			        <input type="hidden" name="id" value="{$this_group.id}" />
                    <button type="submit" class="btn btn-success">确 定</button>
                    <button class="btn btn-warning" onclick="javascript:history.back(-1);return false;">返 回</button>
			    </form>
			<!-- </div> -->
            <!-- /访问授权 -->
		<!-- </div>
	</div> -->
    </div>
    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->
    <script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
    <script src="{:config('__public__')}/static/form-3.51/jquery.form.js"></script>
    <link rel="stylesheet" href="{:config('__public__')}/static/artDialog-6.0.4/css/ui-dialog.css">
    <script src="{:config('__public__')}/static/artDialog-6.0.4/dist/dialog-min.js"></script>
    <script src="{:config('__public__')}/Admin/js/ajaxSubmit.js"></script>


<script type="text/javascript" charset="utf-8">
$('select[name=group]').change(function(){
    location.href = this.value;
});

    +function($){
        var rules = [{$this_group.rules}];
        $('.auth_rules').each(function(){
            if( $.inArray( parseInt(this.value,10),rules )>-1 ){
                $(this).prop('checked',true);
            }
            if(this.value==''){
                $(this).closest('span').remove();
            }
        });

        //全选节点
        $('.rules_all').on('change',function(){
            $(this).closest('dl').find('dd').find('input').prop('checked',this.checked);
        });
        $('.rules_row').on('change',function(){
            $(this).closest('.rule_check').find('.child_row').find('input').prop('checked',this.checked);
        });

        // $('.checkbox').each(function(){
        //     $(this).qtip({
        //         content: {
        //             text: $(this).attr('title'),
        //             title: $(this).text()
        //         },
        //         position: {
        //             my: 'bottom center',
        //             at: 'top center',
        //             target: $(this)
        //         },
        //         style: {
        //             classes: 'qtip-dark',
        //             tip: {
        //                 corner: true,
        //                 mimic: false,
        //                 width: 10,
        //                 height: 10
        //             }
        //         }
        //     });
        // });

        $('select[name=group]').change(function(){
            location.href = this.value;
        });

    }(jQuery);
</script>
</body>
</html>
